require 'watir'
include Watir
require 'test/unit'
require '../watir.config.rb'
require '../resources/functions.rb'
require 'win32ole'
require 'win32/process'

class TC_BlogThemes_test < Test::Unit::TestCase
   
    def startup
      $GroupName= 'group1'
      $GroupDescription = 'This is the first group for creating blogs'
      $SectionName = 'BloG1'
      $AppKey ='BlogAppKey'
      $Owners = 'admin'
      $Url = 'http://communityserver.com'      
      $FilePath = '../resources/Images/gallery_slideshow.gif'
      $FilePath1 ='../resources/Images/gallery_slideshow.gif'
      $BlogTitleHeight= '432432'
      @@ie = Watir::IE.start($SITE_URL)
    end
    
    def ie
      if defined? @@ie
        @@ie
      else
        startup
      end
    end
    
     def test_0000
        require 'win32/process'
        $pid = Process.create(
        :app_name      => 'ruby ../resources/clickers.rb',
        :creation_flags  => Process::DETACHED_PROCESS
        ).process_id

    end  
    
    def test_01_verifyHomeText
        assert(ie.contains_text(/Community Server/))		
    end
      
    def test_02_verifyLoginLinksExist
      if !(ie.link(:text, 'Sign in').exists?)
        ie.goto($SITE_URL + 'logout.aspx')
        ie.refresh
        ie.goto($SITE_URL)
        ie.refresh
      end
	  end
    
    def test_03_navigateToLogin
        ie.link(:text, 'Sign in').click
        assert(ie.contains_text("Sign in name"))
    end
	  
	  def test_04_populateLoginForm
        ie.text_field(:id, /username$/).value = $ADMIN_USER
        assert(ie.text_field(:id, /username$/).verify_contains($ADMIN_USER))
      
        ie.text_field(:id, /password$/).value = $ADMIN_PASSWORD
        assert(ie.text_field(:id, /password$/).verify_contains($ADMIN_PASSWORD))
	  end
	  
    def test_05_submitLoginForm
        if(ie.button(:id, /loginButton$/).exists?)
          ie.button(:id, /loginButton$/).click
        else
        ie.link(:id, /loginButton$/).click
        end
        test_01_verifyHomeText
    end
    
    def test_06_verifyControlPanel
        assert(ie.link(:text, /Control Panel/).exists?)
        ie.link(:text, /Control Panel/).click
        assert(ie.contains_text(/Announcements/))
        assert(ie.link(:text, /System Administration/).exists?)
        ie.link(:text, /System Administration/).click
        assert(ie.contains_text(/Announcements/))
    end
    
    def test_07_verifyControlPanelLinks
        assert_equal $SITE_URL + 'controlpanel/', ie.link(:text, 'Dashboard').href
        assert_equal $SITE_URL + 'controlpanel/setup.aspx', ie.link(:text, 'Administration').href
        assert_equal $SITE_URL + 'controlpanel/BlogAdmin/', ie.link(:text, 'Blog Administration').href
        assert_equal $SITE_URL + 'controlpanel/MediaGalleryAdmin/', ie.link(:text, 'Media Galleries Administration').href
        assert_equal $SITE_URL + 'controlpanel/Forums/', ie.link(:text, 'Forum Administration').href
        assert_equal $SITE_URL + 'controlpanel/HubAdmin/', ie.link(:text, 'Group Administration').href
        assert_equal $SITE_URL + 'controlpanel/Membership/membersearch.aspx?SelectedNavItem=BrowseMembers', ie.link(:text, 'Membership Administration').href
        assert_equal $SITE_URL + 'controlpanel/Settings/default.aspx', ie.link(:text, 'Site Administration').href
    end
    
    def test_08_navigateToBlogAdministration
        ie.goto($SITE_URL + 'controlpanel/BlogAdmin/')
        assert(ie.contains_text('Blog Administration'))      
    end  
    def test_09_verifyLinksExist
      # Make sure that all of the links exist
        assert(ie.link(:text, 'Log Out').exists?)
        assert(ie.link(:text, 'Help').exists?)
        assert(ie.link(:text, 'Go to Site').exists?)
        assert(ie.link(:text, 'Dashboard').exists?)
        
        assert(ie.link(:text, 'Blog Administration').exists?)
        assert(ie.link(:text, 'Telligent').exists?)
    end
    def test_10_navigateToCreateGroup 
        ie.goto($SITE_URL +'controlpanel/BlogAdmin/Groups.aspx')
        assert(ie.button(:value,'Add New Group').exists?)
        ie.button(:value,'Add New Group').click
        assert(ie.text_field(:id,/GroupName$/).exists?)
        ie.text_field(:id,/GroupName$/).value =$GroupName
        assert(ie.text_field(:id,/GroupDesc$/).exists?)
        ie.text_field(:id,/GroupDesc$/).value =$GroupDescription
        assert(ie.button(:id,/SaveButton$/).exists?)
        ie.button(:id,/SaveButton$/).click
    end
    def test_11_CreateBlog
        ie.goto($SITE_URL +'controlpanel/BlogAdmin/sectionedit.aspx')
        assert(ie.text_field(:id,/SectionName$/).exists?)
        ie.text_field(:id,/SectionName$/).value =$SectionName
        assert(ie.text_field(:id,/AppKey$/).exists?)
        ie.text_field(:id,/AppKey$/).value =$AppKey
        assert(ie.text_field(:id,/Owners_ctl00$/).exists?)
        ie.text_field(:id,/Owners_ctl00$/).value =$Owners
        assert(ie.select_list(:id,/AdminGroupList$/).exists?)
        ie.select_list(:id,/AdminGroupList$/).select($GroupName)
        assert(ie.button(:id,/SaveButton$/).exists?)
        ie.button(:id,/SaveButton$/).click
    end
    
    def test_12_navigateToBlogThemes
        sleep 3
        ie.goto($SITE_URL+'controlpanel/BlogAdmin/Blogs.aspx')
        assert(ie.link(:text,'All').exists?)
        ie.link(:text,'All').click
        assert(ie.table(:id,'BlogLists').exists?)
        table1 = ie.table(:id,'BlogLists')
        rows = table1.row_count
        rowcount1 =1
        while rowcount1<=rows
            if (table1[rowcount1][1].link(:text,$SectionName).exists?)
               table1[rowcount1][5].button(:value ,'Manage').click
                break
             end   
         rowcount1=rowcount1+1
        end
        sleep 3
        ie.goto($SITE_URL + 'controlpanel/blogs/ThemeConfiguration.aspx')
        sleep 2
        assert(ie.select_list(:id,/Themes_state$/).exists?)
        ie.select_list(:id,/Themes_state$/).select('Gold Coast')
        sleep 2
        # Variations / General
        # Theme Variations
        assert(ie.select_list(:name,/ctl03$/).exists?)
        sleep 2
        ie.select_list(:name,/ctl03$/).select('Light and Sidebar on Left')
        sleep 2
        # General Content
        assert(ie.text_field(:id,/ConfigurationForm_ctl14_ctl03_text$/).exists?)
        sleep 1
        ie.text_field(:id,/ConfigurationForm_ctl14_ctl03_text$/).set('#fffeef')
        sleep 1
        assert(ie.select_list(:id,/ConfigurationForm_ctl15_ctl03_state$/).exists?)
        sleep 1
        ie.select_list(:id,/ConfigurationForm_ctl15_ctl03_state$/).select('Georgia')
        sleep 1
        # Links
        assert(ie.text_field(:id,/ConfigurationForm_ctl18_ctl03_text$/).exists?)
        sleep 1
        ie.text_field(:id,/ConfigurationForm_ctl18_ctl03_text$/).set('#c74747')
        sleep 1
        ie.button(:value,'OK').click
        sleep 1
        assert(ie.text_field(:id,/ConfigurationForm_ctl19_ctl03_text$/).exists?)
        sleep 1
        ie.text_field(:id,/ConfigurationForm_ctl19_ctl03_text$/).set('#98958d')
        sleep 1
        ie.button(:value,'OK').click
        sleep 1
        assert(ie.text_field(:id,/ConfigurationForm_ctl20_ctl03_text$/).exists?)
        sleep 1
        ie.text_field(:id,/ConfigurationForm_ctl20_ctl03_text$/).set('#7b7051')
        sleep 1
        ie.button(:value,'OK').click
        sleep 1
        # Background
        assert(ie.text_field(:id, /ConfigurationForm_ctl23_ctl03_text$/).exists?)
        sleep 1
        ie.text_field(:id, /ConfigurationForm_ctl23_ctl03_text$/).set('#957272')
        sleep 1
        ie.button(:value,'OK').click
        sleep 1
        assert(ie.button(:id,/ConfigurationForm_ctl24_Button$/).exists?)
        ie.button(:id,/ConfigurationForm_ctl24_Button$/).click
        sleep 5
        assert(ie.frame(:index,1).hidden(:id,'ctl00_bcr_ctl00_ctl00_Tree').exists?)
        hiddenvalue=ie.frame(:index,1).hidden(:id,'ctl00_bcr_ctl00_ctl00_Tree').value
   
        hiddenvaluearr=hiddenvalue.split('&')
        hiddenvaluearr1=hiddenvaluearr[0].split('=')

        #ie.ie.frame(:index,2).contentWindow.execScript("ctl00_bcr_ctl00_ctl00_Tree.SelectNode(ctl00_bcr_ctl00_ctl00_Tree.GetNodeByValue('"+hiddenvaluearr1[1]+"'))")
        assert(ie.frame(:index,1).text_field(:id,'ctl00_bcr_ctl00_ctl00_width').exists?)
        ie.frame(:index,1).text_field(:id,'ctl00_bcr_ctl00_ctl00_width').value ='200'
        assert(ie.frame(:index,1).text_field(:id,'ctl00_bcr_ctl00_ctl00_height').exists?)
        ie.frame(:index,1).text_field(:id,'ctl00_bcr_ctl00_ctl00_height').value ='200'
        #ie.ie.Document.contentWindow.execScript("ctl00_bcr_ctl00_ctl00_ctl01.SelectTab(ctl00_bcr_ctl00_ctl00_ctl01.GetTabAtIndex(1))")
        assert(ie.frame(:index,1).fileField(:name,'ctl00$bcr$ctl00$ctl00$ctl08').exists?)
        ie.frame(:index,1).fileField(:name,'ctl00$bcr$ctl00$ctl00$ctl08').set($SetPath)
        assert(ie.frame(:index,1).button(:value,'Upload File').exists?)
        ie.frame(:index,1).button(:value,'Upload File').click
        assert(ie.frame(:index,1).link(:id,/SelectButton$/).exists?)
        ie.frame(:index,1).link(:id,/SelectButton$/).click
         
        # Header
        ie.ie.Document.parentWindow.execScript("ctl00_ctl00_OuterTaskRegion_TaskRegion_TaskRegion_ConfigurationForm_ctl00.SelectTab(ctl00_ctl00_OuterTaskRegion_TaskRegion_TaskRegion_ConfigurationForm_ctl00.GetTabAtIndex(1))")
        # Site Title
        assert(ie.text_field(:id,/ConfigurationForm_ctl32_ctl03_text$/).exists?)
        ie.text_field(:id,/ConfigurationForm_ctl32_ctl03_text$/).set($BlogTitleHeight)
        
        assert(ie.button(:id,/ConfigurationForm_ctl33_Button$/).exists?)
        ie.button(:id,/ConfigurationForm_ctl33_Button$/).click
        sleep 5
        assert(ie.frame(:index,1).hidden(:id,'ctl00_bcr_ctl00_ctl00_Tree').exists?)
        hiddenvalue=ie.frame(:index,1).hidden(:id,'ctl00_bcr_ctl00_ctl00_Tree').value
        
        hiddenvaluearr=hiddenvalue.split('&')
        hiddenvaluearr1=hiddenvaluearr[0].split('=')
        
        #ie.ie.frame(:index,2).contentWindow.execScript("ctl00_bcr_ctl00_ctl00_Tree.SelectNode(ctl00_bcr_ctl00_ctl00_Tree.GetNodeByValue('"+hiddenvaluearr1[1]+"'))")
        assert(ie.frame(:index,1).text_field(:id,'ctl00_bcr_ctl00_ctl00_width').exists?)
        ie.frame(:index,1).text_field(:id,'ctl00_bcr_ctl00_ctl00_width').value ='200'
        assert(ie.frame(:index,1).text_field(:id,'ctl00_bcr_ctl00_ctl00_height').exists?)
        ie.frame(:index,1).text_field(:id,'ctl00_bcr_ctl00_ctl00_height').value ='200'
        #ie.ie.Document.contentWindow.execScript("ctl00_bcr_ctl00_ctl00_ctl01.SelectTab(ctl00_bcr_ctl00_ctl00_ctl01.GetTabAtIndex(1))")
        assert(ie.frame(:index,1).fileField(:name,'ctl00$bcr$ctl00$ctl00$ctl08').exists?)
        ie.frame(:index,1).fileField(:name,'ctl00$bcr$ctl00$ctl00$ctl08').set($SetPath)
        assert(ie.frame(:index,1).button(:value,'Upload File').exists?)
        ie.frame(:index,1).button(:value,'Upload File').click
        assert(ie.frame(:index,1).link(:id,/SelectButton$/).exists?)
        ie.frame(:index,1).link(:id,/SelectButton$/).click
        
        assert(ie.text_field(:id,/ConfigurationForm_ctl34_ctl03_text$/).exists?)
        sleep 1
        ie.text_field(:id,/ConfigurationForm_ctl34_ctl03_text$/).set('#938151')
        sleep 1
        ie.button(:value,'OK').click
        sleep 1
        assert(ie.select_list(:id,/ConfigurationForm_ctl35_ctl03_state$/).exists?)
        sleep 1
        ie.select_list(:id,/ConfigurationForm_ctl35_ctl03_state$/).select('Helvetica')
        sleep 1
        assert(ie.select_list(:id,/ConfigurationForm_ctl36_ctl03_state$/).exists?)
        sleep 1
        ie.select_list(:id,/ConfigurationForm_ctl36_ctl03_state$/).select('Larger')
        sleep 1
      
        # Body
        ie.ie.Document.parentWindow.execScript("ctl00_ctl00_OuterTaskRegion_TaskRegion_TaskRegion_ConfigurationForm_ctl00.SelectTab(ctl00_ctl00_OuterTaskRegion_TaskRegion_TaskRegion_ConfigurationForm_ctl00.GetTabAtIndex(2))")
        # Page Title
        assert(ie.text_field(:id,/ConfigurationForm_ctl44_ctl03_text$/).exists?)
        sleep 1
        ie.text_field(:id,/ConfigurationForm_ctl44_ctl03_text$/).set('#8a2b2b')
        sleep 1
        ie.button(:value,'OK').click
        sleep 1
        assert(ie.select_list(:id,/ConfigurationForm_ctl35_ctl03_state$/).exists?)
        sleep 1
        ie.select_list(:id,/ConfigurationForm_ctl35_ctl03_state$/).select('Courier New')
        sleep 1
        assert(ie.select_list(:id,/ConfigurationForm_ctl36_ctl03_state$/).exists?)
        sleep 1
        ie.select_list(:id,/ConfigurationForm_ctl36_ctl03_state$/).select('Medium')
        sleep 1
        # Sub Title
        
        assert(ie.text_field(:id,/ConfigurationForm_ctl49_ctl03_text$/).exists?)
        sleep 1
        ie.text_field(:id,/ConfigurationForm_ctl49_ctl03_text$/).set('#7f724f')
        sleep 1
        ie.button(:value,'OK').click
        sleep 1
        assert(ie.select_list(:id,/ConfigurationForm_ctl50_ctl03_state$/).exists?)
        sleep 1
        ie.select_list(:id,/ConfigurationForm_ctl50_ctl03_state$/).select('Courier New')
        sleep 1
        assert(ie.select_list(:id,/ConfigurationForm_ctl51_ctl03_state$/).exists?)
        sleep 1
        ie.select_list(:id,/ConfigurationForm_ctl51_ctl03_state$/).select('Medium')
        sleep 1
        # Lists
        assert(ie.text_field(:id,/ConfigurationForm_ctl54_ctl03_text$/).exists?)
        sleep 1
        ie.text_field(:id,/ConfigurationForm_ctl54_ctl03_text$/).set('#8f7c7c')
        sleep 1
        ie.button(:value,'OK').click
        sleep 1
        assert(ie.button(:id,/ConfigurationForm_ctl55_Button$/).exists?)
        ie.button(:id,/ConfigurationForm_ctl55_Button$/).click
        sleep 5
        assert(ie.frame(:index,1).hidden(:id,'ctl00_bcr_ctl00_ctl00_Tree').exists?)
        hiddenvalue=ie.frame(:index,1).hidden(:id,'ctl00_bcr_ctl00_ctl00_Tree').value
        
        hiddenvaluearr=hiddenvalue.split('&')
        hiddenvaluearr1=hiddenvaluearr[0].split('=')
        
        #ie.ie.frame(:index,2).contentWindow.execScript("ctl00_bcr_ctl00_ctl00_Tree.SelectNode(ctl00_bcr_ctl00_ctl00_Tree.GetNodeByValue('"+hiddenvaluearr1[1]+"'))")
        assert(ie.frame(:index,1).text_field(:id,'ctl00_bcr_ctl00_ctl00_width').exists?)
        ie.frame(:index,1).text_field(:id,'ctl00_bcr_ctl00_ctl00_width').value ='200'
        assert(ie.frame(:index,1).text_field(:id,'ctl00_bcr_ctl00_ctl00_height').exists?)
        ie.frame(:index,1).text_field(:id,'ctl00_bcr_ctl00_ctl00_height').value ='200'
        #ie.ie.Document.contentWindow.execScript("ctl00_bcr_ctl00_ctl00_ctl01.SelectTab(ctl00_bcr_ctl00_ctl00_ctl01.GetTabAtIndex(1))")
        assert(ie.frame(:index,1).fileField(:name,'ctl00$bcr$ctl00$ctl00$ctl08').exists?)
        ie.frame(:index,1).fileField(:name,'ctl00$bcr$ctl00$ctl00$ctl08').set($SetPath)
        assert(ie.frame(:index,1).button(:value,'Upload File').exists?)
        ie.frame(:index,1).button(:value,'Upload File').click
        assert(ie.frame(:index,1).link(:id,/SelectButton$/).exists?)
        ie.frame(:index,1).link(:id,/SelectButton$/).click
        
        # 	Sidebar
        ie.ie.Document.parentWindow.execScript("ctl00_ctl00_OuterTaskRegion_TaskRegion_TaskRegion_ConfigurationForm_ctl00.SelectTab(ctl00_ctl00_OuterTaskRegion_TaskRegion_TaskRegion_ConfigurationForm_ctl00.GetTabAtIndex(3))")
        # Sidebar Header
        sleep 1
        assert(ie.text_field(:id,/ConfigurationForm_ctl67_ctl03_text$/).exists?)
        sleep 1
        ie.text_field(:id,/ConfigurationForm_ctl67_ctl03_text$/).set('#a07979')
        sleep 1
        ie.button(:value,'OK').click
        sleep 1
        assert(ie.select_list(:id,/ConfigurationForm_ctl68_ctl03_state$/).exists?)
        sleep 1
        ie.select_list(:id,/ConfigurationForm_ctl68_ctl03_state$/).select('Courier New')
        sleep 1
        assert(ie.select_list(:id,/ConfigurationForm_ctl69_ctl03_state$/).exists?)
        sleep 1
        ie.select_list(:id,/ConfigurationForm_ctl69_ctl03_state$/).select('Medium')
        sleep 1
        # Sidebar Content
        assert(ie.text_field(:id,/ConfigurationForm_ctl72_ctl03_text$/).exists?)
        sleep 1
        ie.text_field(:id,/ConfigurationForm_ctl72_ctl03_text$/).set('#913b3b')
        sleep 1
        ie.button(:value,'OK').click
        sleep 1
        assert(ie.select_list(:id,/ConfigurationForm_ctl73_ctl03_state$/).exists?)
        sleep 1
        ie.select_list(:id,/ConfigurationForm_ctl73_ctl03_state$/).select('Verdana')
        sleep 1
        assert(ie.select_list(:id,/ConfigurationForm_ctl74_ctl03_state$/).exists?)
        sleep 1
        ie.select_list(:id,/ConfigurationForm_ctl74_ctl03_state$/).select('Larger')
        # Sidebar Links 
        sleep 1
        assert(ie.text_field(:id,/ConfigurationForm_ctl77_ctl03_text$/).exists?)
        sleep 1
        ie.text_field(:id,/ConfigurationForm_ctl77_ctl03_text$/).set('#837b64')
        sleep 1
        ie.button(:value,'OK').click
        sleep 1
        assert(ie.text_field(:id,/ConfigurationForm_ctl78_ctl03_text$/).exists?)
        sleep 1
        ie.text_field(:id,/ConfigurationForm_ctl78_ctl03_text$/).set('#6d6349')
        sleep 1
        ie.button(:value,'OK').click
        sleep 1
        assert(ie.text_field(:id,/ConfigurationForm_ctl79_ctl03_text$/).exists?)
        sleep 1
        ie.text_field(:id,/ConfigurationForm_ctl79_ctl03_text$/).set('#6d6349')
        ie.button(:value,'OK').click
        sleep 1
        # Sidebar Widgets 
  
        assert(ie.select_list(:id,/ConfigurationForm_ctl82_cfoptions_state$/).exists?)
        ie.select_list(:id,/ConfigurationForm_ctl82_cfoptions_state$/).select('Blog Search Form')
        assert(ie.button(:id ,/ConfigurationForm_ctl82_addButton$/).exists?)
        ie.button(:id ,/ConfigurationForm_ctl82_addButton$/).click
        sleep 2
        assert(ie.select_list(:id,/ConfigurationForm_ctl82_cfoptions_state$/).exists?)
        ie.select_list(:id,/ConfigurationForm_ctl82_cfoptions_state$/).select('Blog Recent Posts')
        assert(ie.button(:id ,/ConfigurationForm_ctl82_addButton$/).exists?)
        ie.button(:id ,/ConfigurationForm_ctl82_addButton$/).click
        sleep 2
        assert(ie.select_list(:id,/ConfigurationForm_ctl82_cfoptions_state$/).exists?)
        ie.select_list(:id,/ConfigurationForm_ctl82_cfoptions_state$/).select('Blog Link Category List')
        assert(ie.button(:id ,/ConfigurationForm_ctl82_addButton$/).exists?)
        ie.button(:id ,/ConfigurationForm_ctl82_addButton$/).click
        sleep 5
        ie.ie.Document.parentWindow.execScript("ctl00_ctl00_OuterTaskRegion_TaskRegion_TaskRegion_ConfigurationForm_ctl82_cflist.SelectItem(ctl00_ctl00_OuterTaskRegion_TaskRegion_TaskRegion_ConfigurationForm_ctl82_cflist.GetItemCount()-1,true)")
        assert(ie.button(:id,'ctl00_ctl00_OuterTaskRegion_TaskRegion_TaskRegion_ConfigurationForm_ctl82_ctl00_ctl00_OuterTaskRegion_TaskRegion_TaskRegion_ConfigurationForm_ctl82_cflist_up').exists?)
        ie.button(:id,'ctl00_ctl00_OuterTaskRegion_TaskRegion_TaskRegion_ConfigurationForm_ctl82_ctl00_ctl00_OuterTaskRegion_TaskRegion_TaskRegion_ConfigurationForm_ctl82_cflist_up').fire_event "onclick"
        sleep 2
        ie.ie.Document.parentWindow.execScript("ctl00_ctl00_OuterTaskRegion_TaskRegion_TaskRegion_ConfigurationForm_ctl82_cflist.SelectItem(ctl00_ctl00_OuterTaskRegion_TaskRegion_TaskRegion_ConfigurationForm_ctl82_cflist.GetItemCount()-2,true)")
        assert(ie.button(:id,'ctl00_ctl00_OuterTaskRegion_TaskRegion_TaskRegion_ConfigurationForm_ctl82_ctl00_ctl00_OuterTaskRegion_TaskRegion_TaskRegion_ConfigurationForm_ctl82_cflist_up').exists?)
        ie.button(:id,'ctl00_ctl00_OuterTaskRegion_TaskRegion_TaskRegion_ConfigurationForm_ctl82_ctl00_ctl00_OuterTaskRegion_TaskRegion_TaskRegion_ConfigurationForm_ctl82_cflist_up').fire_event "onclick"
        sleep 2
        ie.ie.Document.parentWindow.execScript("ctl00_ctl00_OuterTaskRegion_TaskRegion_TaskRegion_ConfigurationForm_ctl82_cflist.SelectItem(ctl00_ctl00_OuterTaskRegion_TaskRegion_TaskRegion_ConfigurationForm_ctl82_cflist.GetItemCount()-3,true)")
        assert(ie.button(:id,'ctl00_ctl00_OuterTaskRegion_TaskRegion_TaskRegion_ConfigurationForm_ctl82_ctl00_ctl00_OuterTaskRegion_TaskRegion_TaskRegion_ConfigurationForm_ctl82_cflist_up').exists?)
        ie.button(:id,'ctl00_ctl00_OuterTaskRegion_TaskRegion_TaskRegion_ConfigurationForm_ctl82_ctl00_ctl00_OuterTaskRegion_TaskRegion_TaskRegion_ConfigurationForm_ctl82_cflist_up').fire_event "onclick"
        sleep 2
        ie.ie.Document.parentWindow.execScript("ctl00_ctl00_OuterTaskRegion_TaskRegion_TaskRegion_ConfigurationForm_ctl82_cflist.SelectItem(ctl00_ctl00_OuterTaskRegion_TaskRegion_TaskRegion_ConfigurationForm_ctl82_cflist.GetItemCount()-4,true)")
        assert(ie.button(:id,'ctl00_ctl00_OuterTaskRegion_TaskRegion_TaskRegion_ConfigurationForm_ctl82_ctl00_ctl00_OuterTaskRegion_TaskRegion_TaskRegion_ConfigurationForm_ctl82_cflist_up').exists?)
        ie.button(:id,'ctl00_ctl00_OuterTaskRegion_TaskRegion_TaskRegion_ConfigurationForm_ctl82_ctl00_ctl00_OuterTaskRegion_TaskRegion_TaskRegion_ConfigurationForm_ctl82_cflist_up').fire_event "onclick"
        sleep 2
        ie.ie.Document.parentWindow.execScript("ctl00_ctl00_OuterTaskRegion_TaskRegion_TaskRegion_ConfigurationForm_ctl82_cflist.SelectItem(ctl00_ctl00_OuterTaskRegion_TaskRegion_TaskRegion_ConfigurationForm_ctl82_cflist.GetItemCount()-3,true)")
        assert(ie.button(:id,'ctl00_ctl00_OuterTaskRegion_TaskRegion_TaskRegion_ConfigurationForm_ctl82_ctl00_ctl00_OuterTaskRegion_TaskRegion_TaskRegion_ConfigurationForm_ctl82_cflist_down').exists?)
        ie.button(:id,'ctl00_ctl00_OuterTaskRegion_TaskRegion_TaskRegion_ConfigurationForm_ctl82_ctl00_ctl00_OuterTaskRegion_TaskRegion_TaskRegion_ConfigurationForm_ctl82_cflist_down').fire_event "onclick"
        sleep 2
        ie.ie.Document.parentWindow.execScript("ctl00_ctl00_OuterTaskRegion_TaskRegion_TaskRegion_ConfigurationForm_ctl82_cflist.SelectItem(ctl00_ctl00_OuterTaskRegion_TaskRegion_TaskRegion_ConfigurationForm_ctl82_cflist.GetItemCount()-2,true)")
        assert(ie.button(:id,'ctl00_ctl00_OuterTaskRegion_TaskRegion_TaskRegion_ConfigurationForm_ctl82_ctl00_ctl00_OuterTaskRegion_TaskRegion_TaskRegion_ConfigurationForm_ctl82_cflist_down').exists?)
        ie.button(:id,'ctl00_ctl00_OuterTaskRegion_TaskRegion_TaskRegion_ConfigurationForm_ctl82_ctl00_ctl00_OuterTaskRegion_TaskRegion_TaskRegion_ConfigurationForm_ctl82_cflist_down').fire_event "onclick"
        sleep 2
        ie.ie.Document.parentWindow.execScript("ctl00_ctl00_OuterTaskRegion_TaskRegion_TaskRegion_ConfigurationForm_ctl82_cflist.SelectItem(ctl00_ctl00_OuterTaskRegion_TaskRegion_TaskRegion_ConfigurationForm_ctl82_cflist.GetItemCount()-1,true)")
        assert(ie.button(:id,'ctl00_ctl00_OuterTaskRegion_TaskRegion_TaskRegion_ConfigurationForm_ctl82_ctl00_ctl00_OuterTaskRegion_TaskRegion_TaskRegion_ConfigurationForm_ctl82_cflist_down').exists?)
        ie.button(:id,'ctl00_ctl00_OuterTaskRegion_TaskRegion_TaskRegion_ConfigurationForm_ctl82_ctl00_ctl00_OuterTaskRegion_TaskRegion_TaskRegion_ConfigurationForm_ctl82_cflist_down').fire_event "onclick"
        sleep 2
        assert(ie.button(:id,'ctl00_ctl00_OuterTaskRegion_TaskRegion_TaskRegion_ConfigurationForm_ctl82_ctl00_ctl00_OuterTaskRegion_TaskRegion_TaskRegion_ConfigurationForm_ctl82_cflist_delete').exists?)
        ie.button(:id,'ctl00_ctl00_OuterTaskRegion_TaskRegion_TaskRegion_ConfigurationForm_ctl82_ctl00_ctl00_OuterTaskRegion_TaskRegion_TaskRegion_ConfigurationForm_ctl82_cflist_delete').fire_event "onclick"
        # Custom Styles (Advanced)
        ie.ie.Document.parentWindow.execScript("ctl00_ctl00_OuterTaskRegion_TaskRegion_TaskRegion_ConfigurationForm_ctl00.SelectTab(ctl00_ctl00_OuterTaskRegion_TaskRegion_TaskRegion_ConfigurationForm_ctl00.GetTabAtIndex(4))")
        sleep 5
        assert(ie.text_field(:name,'ctl00$ctl00$OuterTaskRegion$TaskRegion$TaskRegion$ConfigurationForm$ctl89$ctl03').exists?)
        sleep 5
        ie.text_field(:name,'ctl00$ctl00$OuterTaskRegion$TaskRegion$TaskRegion$ConfigurationForm$ctl89$ctl03').set('body{font-size:16px;background-color:white;color:black;}')
        # Preview
        ie.ie.Document.parentWindow.execScript("ctl00_ctl00_OuterTaskRegion_TaskRegion_TaskRegion_ConfigurationForm_ctl00.SelectTab(ctl00_ctl00_OuterTaskRegion_TaskRegion_TaskRegion_ConfigurationForm_ctl00.GetTabAtIndex(5))")
        assert(ie.link(:text,'Start Live Preview').exists?)
        ie.link(:text,'Start Live Preview').click
        sleep 10
        ie.ie.Document.parentWindow.execScript("ctl00_ctl00_OuterTaskRegion_TaskRegion_TaskRegion_ConfigurationForm_ctl00.SelectTab(ctl00_ctl00_OuterTaskRegion_TaskRegion_TaskRegion_ConfigurationForm_ctl00.GetTabAtIndex(5))")
        assert(ie.link(:text,'Open New Preview Window').exists?)
        ie.link(:text,'Open New Preview Window').click
        sleep 10
        ie.ie.Document.parentWindow.execScript("ctl00_ctl00_OuterTaskRegion_TaskRegion_TaskRegion_ConfigurationForm_ctl00.SelectTab(ctl00_ctl00_OuterTaskRegion_TaskRegion_TaskRegion_ConfigurationForm_ctl00.GetTabAtIndex(5))")
        assert(ie.link(:text,'Stop Live Preview').exists?)
        ie.link(:text,'Stop Live Preview').click
        sleep 10
        #Apply Changes
        assert(ie.button(:id,/SaveButton$/).exists?)
        ie.button(:id,/SaveButton$/).click
        sleep 5
        #~ #Export
        #~ assert(ie.button(:id,/ExportConfiguration$/).exists?)
        #~ ie.button(:id,/ExportConfiguration$/).click
        #Import Themes
        assert(ie.button(:id,/ImportButton$/).exists?)
        ie.button(:id,/ImportButton$/).click
        assert(ie.frame(:index,1).fileField(:id,/File$/).exists?)
        ie.frame(:index,1).fileField(:id,/File$/).set($FilePath1)
        assert(ie.frame(:index,1).link(:id,/ImportButton$/).exists?)
        ie.frame(:index,1).link(:id,/ImportButton$/).click
        #Restore Defaults
        assert(ie.button(:id,/RestoreDefaultsButton$/).exists?)
        ie.button(:id,/RestoreDefaultsButton$/).click
        #Apply Changes
        assert(ie.button(:id,/SaveButton$/).exists?)
        ie.button(:id,/SaveButton$/).click     
     end
     
     def test_13_navigateToDeleteBlog
        ie.goto($SITE_URL+'controlpanel/BlogAdmin/Blogs.aspx')
        assert(ie.table(:id,'BlogLists').exists?)
        table1 = ie.table(:id,'BlogLists')
        rowcount = table1.row_count
        rowcount1 =1
        ok = 0
        while rowcount1<=rowcount
            if (table1[rowcount1][1].link(:text,$SectionName).exists?)
              ok =1
               sleep 5
               table1[rowcount1][5].button(:value,'Delete' ).click
               break
            end   
            rowcount1=rowcount1+1
        end
      end
      
    def test_14_navigateToDeleteBlogGroup
        ie.goto($SITE_URL+'controlpanel/BlogAdmin/Groups.aspx')
        assert(ie.table(:id,'GroupLists').exists?)
        table2 = ie.table(:id,'GroupLists')
        rows = table2.row_count
        rowcount2 =1
        ok = 0
        while rowcount2<=rows
            if (table2[rowcount2][1].link(:text,$GroupName).exists?)
              ok =1
               sleep 5
               table2[rowcount2][3].button(:value,'Delete' ).click
               sleep 5
               break
            end   
         rowcount2=rowcount2+1
        end
      end
      
     
  def test_99_Exit
      ie.close
      end
end 